#include<bits/stdc++.h>
#define int long long 
#define endl "\n"

using namespace std;

int n, m, q;
int a[20][20];
int b[20][20][20];
vector<int>ret;

bool check(vector<int> v) {
	if(v.size() == 0) {
		return false;
	}
	
	int t[20][20];
	memset(t, 0, sizeof t);
	
	for(int i = 1; i <= n; i ++ ) {
		for(int j = 1; j <= m; j ++ ) {
			for(int k = 0; k < v.size(); k ++ ) {
				int x = v[k];
				t[i][j] = max(t[i][j], b[x][i][j]);
			}
		}
	}
	
	for(int i = 1; i <= n; i ++ ) {
		for(int j = 1; j <= m; j ++ ) {
			if(a[i][j] == t[i][j]) {
				return false;
			}
		}
	}
	return true;
}

void dfs(int len, vector<int>t ) {
	if(len == q + 1) {
		if(check(t)) {
			if(ret.size() == 0 || t.size() < ret.size() ) {
				ret = t;
			}
		}
		return ;
	}
	t.push_back(len);
	dfs(len + 1, t);
	t.pop_back();
	dfs(len + 1, t);
}

signed main() {
	cin >> n >> m >> q;
	for(int i = 1; i <= n; i ++ ) {
		string s;
		cin >> s;
		for(int j = 1; j <= m; j ++ ) {
			a[i][j] = s[j - 1] - '0';
		}
	}
	
	for(int p = 1; p <= q; p ++ ) {
		for(int i = 1; i <= n; i ++ ) {
			string s;
			cin >> s;
			for(int j = 1; j <= m; j ++ ) {
				b[p][i][j] = s[j - 1] - '0';
			}
		}
	}
	
	vector<int>t;
	dfs(1, t);
	
	if(ret.size() == 0) {
		cout << -1 << endl;
		return 0;
	}
	
	cout << ret.size() << endl;
	for(int i = 0; i < ret.size(); i ++ ) {
		cout << ret[i] << " ";
	}
	
	return 0;
}
